Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Treat self referrals as direct #1426

Closed
wants to merge 2 commits into from

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Sep 20, 2024

Changes

We handle the $referrer property in a potentially confusing way when an internal link is clicked. The latest example is https://posthog.slack.com/archives/C03C60FT1J7/p1726670676997629.

This happens because we use document.referrer directly, and this can be self-referential in the following example

  1. User is on https://referrer.com
  2. User clicks a link to https://tracked.com
  3. Referrer is referrer.com
  4. User is inactive long enough for the session to expire
  5. User clicks an internal link to https://tracked.com
  6. Referrer is tracked.com

This PR changes this, so that the referrer in 6) would be $direct

To be clear about this: it is a breaking change, however I believe it's more in line with what the expected behaviour would be. One might argue that the original behaviour is a bug

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented Sep 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Sep 20, 2024 10:00am

Copy link

github-actions bot commented Sep 20, 2024

Size Change: +303 B (+0.02%)

Total Size: 1.21 MB

Filename Size Change
dist/array.full.js 347 kB +75 B (+0.02%)
dist/array.js 163 kB +76 B (+0.05%)
dist/main.js 164 kB +76 B (+0.05%)
dist/module.js 163 kB +76 B (+0.05%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 10.4 kB
dist/recorder-v2.js 111 kB
dist/recorder.js 111 kB
dist/surveys-preview.js 59.8 kB
dist/surveys.js 66 kB
dist/tracing-headers.js 8.26 kB
dist/web-vitals.js 10.3 kB

compressed-size-action

@pauldambra
Copy link
Member

Asked a question about this in the private slack posthog.slack.com/archives/C03C60FT1J7/p1726670676997629

@robbie-c
Copy link
Member Author

Closing PR following discussion on slack

@robbie-c robbie-c closed this Sep 20, 2024
@robbie-c
Copy link
Member Author

See PostHog/posthog.com#9408 (review) instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants